<!doctype html PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<html>
	<head>
		<meta http-equiv="content-type" content="text/html; charset=iso-8859-1">
		<meta http-equiv="content-script-type" content="text/javascript">
		<meta http-equiv="content-style-type" content="text/css">
		<meta name="author" content="Heidi Rakels">
		<meta name="description" content="Sanaware Java Docking - Developer guide - Component Factory">
		<link rel="stylesheet" type="text/css" href="../style.css">
		<title>How to Use the Component Factory</title>
	</head>
<body>

<div class="nextprev">
<nobr><a href="drag.html">&laquo; prev</a></nobr>
<nobr><a href="actions.html">next &raquo;</a></nobr>
</div>

<span class="item"><a href="../main/index.html">Java Docking Home</a></span>&gt;
<span class="item"><a href="index.html">Developer Guide</a></span>&gt;
<span class="selected item">How to Use the Component Factory</span>

<h2>
How to Use the Component Factory
</h2>

<h3>
:: Component Factory ::
</h3>
<p>
The docking library uses a <a href="../javadoc/com/javadocking/component/SwComponentFactory.html" target="_blank">
SwComponentFactory</a> to create the components of the docks, windows, headers, borders, etc...
The component factory can be found in the docking manager.
<blockquote><pre>
		SwComponentFactory componentFactory = DockingManager.getComponentFactory();
</pre></blockquote>
The default component factory, that the docking manager uses, is a <a href="../javadoc/com/javadocking/component/DefaultSwComponentFactory.html" target="_blank">
DefaultSwComponentFactory</a>.
If you want to change the components that the library uses, you have to give your own
component factory to the docking manager.
</p>

<h3>
:: Decorated floating windows ::
</h3>
<p>
The floating windows that the default component factory creates are undecorated.
</p>
<p>
If you want decorated windows, you have to create your own component factory like this:
<blockquote><pre>
	/**
	 * This component factory creates decorated dialogs for the floating windows.
	 * 
	 * @author Heidi Rakels.
	 */
	private class MyComponentFactory extends DefaultSwComponentFactory 
	{

		public JDialog createJDialog(Window owner)
		{
			// Create the dialog.
			JDialog dialog = null;
			if (owner instanceof JDialog)
			{
				dialog = new JDialog((JDialog)owner, ((JDialog)owner).getTitle());
			}
			else if (owner instanceof JFrame)
			{
				dialog =  new JDialog((JFrame)owner, ((JFrame)owner).getTitle());
			}
			else 
			{
				dialog = new JDialog((JFrame)null, "");
			}
			
			return dialog;
		}
		
	}
</pre></blockquote>
Give this component factory to the docking manager:
<blockquote><pre>
		// Give our component factory to the docking manager.
		DockingManager.setComponentFactory(new MyComponentFactory());
</pre></blockquote>
</p>

<h3>
:: Split docks with small dividers ::
</h3>
<p>
The default splits of a javax.swing.JSplitPane are quite big. 
</p>
<p>
If you want smaller divider for the split docks, you have to create your own component factory like this:
<blockquote><pre>
	/**
	 * This component factory creates split panes with small dividers.
	 * 
	 * @author Heidi Rakels.
	 */
	private class MyComponentFactory extends DefaultSwComponentFactory 
	{

		public JSplitPane createJSplitPane()
		{
			
			JSplitPane splitPane = super.createJSplitPane();
			splitPane.setDividerSize(3);
			return splitPane;
		}

	}
</pre></blockquote>
Give this component factory to the docking manager:
<blockquote><pre>
		// Give our component factory to the docking manager.
		DockingManager.setComponentFactory(new MyComponentFactory());
</pre></blockquote>
</p>

<a name="Headers"><!-- --></a>
<h3>
:: Custom headers for the leaf docks and visualizers ::
</h3>
<p>
The library uses a lot of headers. Leaf docks are using headers. Minimizers and maximizers
are also using headers. 
</p>
<p>
The header interfaces:
<ul>
<li><a href="../javadoc/com/javadocking/component/Header.html" target="_blank">Header</a> is the basic interface for all headers.</li>
<li><a href="../javadoc/com/javadocking/component/SelectableHeader.html" target="_blank">Header</a> is for headers that can be selected, like headers in a tab dock.</li>
<li><a href="../javadoc/com/javadocking/component/DockHeader.html" target="_blank">Header</a> is for a header of a leaf dock.</li>
<li></li>
</ul> 
</p>
<p>
The headers of the leaf docks can be used for the following things:
<ul>
	<li>Dragging the dockables.</li>
	<li>Display the names of the dockables.</li>
	<li>Display the icons of the dockables.</li>
	<li>Display the description of the dockable content in a tooltip.</li>
	<li>Display the actions of the dockables.</li>
	<li>Show the popup with the actions of the dockables, when the user does a right clicks on the header.</li>
</ul>
You can provide your own headers in the library.
The component factory is also responsible for creating the headers.
</p>
<p>
The default headers created by the default component factory are:
<ul>
	<li>A <a href="../javadoc/com/javadocking/component/SelectableDockableHeader.html" target="_blank">SelectableDockableHeader</a> for 
		<a href="../javadoc/com/javadocking/dock/TabDock.html" target="_blank">TabDock</a>s.</li>
	<li>A <a href="../javadoc/com/javadocking/component/DefaultSingleDockHeader.html" target="_blank">DefaultSingleDockHeader</a> for 
		<a href="../javadoc/com/javadocking/dock/SingleDock.html" target="_blank">SingleDock</a>s.</li>
	<li>A <a href="../javadoc/com/javadocking/component/DefaultDockHeader.html" target="_blank">DefaultDockHeader</a> for 
		<a href="../javadoc/com/javadocking/dock/LineDock.html" target="_blank">LineDock</a>s and 
		<a href="../javadoc/com/javadocking/dock/GridDock.html" target="_blank">GridDock</a>s.</li>
	<li>A <a href="../javadoc/com/javadocking/component/DefaultMaximizeHeader.html" target="_blank">DefaultMaximizeHeader</a> for 
		<a href="../javadoc/com/javadocking/visualizer/Visualizer.html" target="_blank">Visualizer</a>s that serve as maximizers.</li>
	<li>A <a href="../javadoc/com/javadocking/component/MinimizeHeader.html" target="_blank">MinimizeHeader</a> for 
		<a href="../javadoc/com/javadocking/visualizer/Visualizer.html" target="_blank">Visualizer</a>s that serve as minimizers.</li>
</ul>
</p>

<hr>
<br/>
The source code of the samples can be found in:
<br/><br/>
<table>
<tr>
	<td><a href="code/DecoratedDialogs.java.html">DecoratedDialogs</a></td><td>Shows decorated floating windows.</td>
</tr>
<tr>
	<td><a href="code/SmallDividerSplitDocks.java.html">SmallDividerSplitDocks</a></td><td>Shows split docks with small dividers.</td>
</tr>
</table>

<br/>
<hr>
<br/>

<div class="nextprevbottom">
<nobr><a href="drag.html">&laquo; prev</a></nobr>
<nobr><a href="actions.html">next &raquo;</a></nobr>
</div>

</body>

</html>